package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.MarketMaintain;
import com.sc.nft.entity.vo.MarketMaintainUserVO;
import com.sc.nft.mapper.MarketMaintainMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 市值账号和后台关联(MarketMaintain)表Dao层
 *
 * @author 王伟成
 * @since 2023-10-07 16:23:30
 */
@Slf4j
@Repository
public class MarketMaintainDao extends ServiceImpl<MarketMaintainMapper, MarketMaintain> {


    /**
     * 验证绑定账号是否存在,用来确认用户身份
     *
     * @param adminId
     * @param userId
     * @return
     */
    public Boolean verificationBinding(Long adminId, Long userId) {
        LambdaQueryWrapper<MarketMaintain> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(MarketMaintain::getAdminId, adminId);
        lambdaQueryWrapper.eq(MarketMaintain::getUserId, userId);
        return count(lambdaQueryWrapper) > 0;
    }


    public List<MarketMaintainUserVO> marketMaintainUsers(Long adminId){
        return baseMapper.marketMaintainUsers(adminId);
    }

    public List<Long> getAllMaintainUsers(){
        return baseMapper.getAllMaintainUsers();
    }
}
